/*
Contains:
	world vars
	world procs
	global variables
	global procs
*/

world
	//world vars
	view=16
	turf=/turf/grass
	mob =/player
	name="Mantra"

	//world procs
	New()
		..()
#ifdef DEBUG
		debug("World started up at [time2text(world.timeofday)]", FILE, LINE)
#endif
		for(var/o in typesof(/prefix))
			prefixes += new o
		for(var/o in typesof(/root))
			roots += new o
		for(var/o in typesof(/suffix))
			suffixes += new o

	Del()
		..()
#ifdef DEBUG
		debug("World closed down at [time2text(world.timeofday)]\n\n", FILE, LINE)
#endif

	//global variables

var
	list
		prefixes	=new/list()
		suffixes	=new/list()
		roots		=new/list()

		hiding_spots=new/list()


	//global procs


//TODO: optimize this
proc
	shift_list(list/l)

		var/list/first_half
		var/list/second_half

		for(var/x = 1 to l.len)
			if(l[x] == null)
				first_half = l.Copy(1,x)
				if(x == l.len)
					second_half = new /list()
				else
					second_half = l.Copy(x+1)

		return first_half + second_half

	make_proper(text)
		.=""
		for(var/x=1 to length(text))
			var/ascii = text2ascii(text, x)
			if((ascii<90 && ascii>64) || (ascii>96 && ascii<123)) .+=ascii2text(ascii)
		.=lowertext(.)

	make_new_monster(type, x, y, z, delay)
		spawn(delay)
			new type(locate(x,y,z))

	capitalize(text)
		return uppertext(copytext(text,1,2))+copytext(text,2)


	bar_safe(num, max)
		.=round((num / max) * 100)
		if(. < 0)  		return 0
		if(. > 100)  	return 100